<?php
/**
 * Created by PhpStorm.
 * User: asdf
 * Date: 2021/9/26
 * Time: 19:12
 */

namespace Extentions\template;
use function core\p;

class Template
{
    private static $instance = null;
    public $assign;

    public  function assign($name,$value){
        $this->assign[$name] = $value;
    }

    public function display($file){
        $file = VIEW.$file;
        if (is_file($file)){
            extract($this->assign);
            include $file;
        }
    }


    public function displayFd($file,$path = __DIR__){
        $file = $path.Dirp."..".Dirp."views".Dirp.$file;
        if (is_file($file)){
            extract($this->assign);
            include $file;
        }
    }

    public function displayN($file,$path = __DIR__){
        $file = $path.Dirp."..".Dirp."views".Dirp.$file;
        if (is_file($file)){
            include $file;
        }
    }

    public static function Newinstance(){
        if(!self::$instance instanceof self){
            self::$instance = new self();
        }
        return self::$instance;
    }
}